package approval.dao;

import java.sql.ResultSet;
import java.util.ArrayList;
import resource.pojo.Approvedoc;
import model.pojo.ListApprove;
import models.util.MySqlDataAccessHelper;

public class LstapproveDAO {
	private Approvedoc document;
	private ArrayList<ListApprove> approvers = new ArrayList<ListApprove>();
	private  ArrayList<ListApprove> gApproval(){
		MySqlDataAccessHelper mysqlHelper = new MySqlDataAccessHelper();
		mysqlHelper.open();
		try {
			ResultSet rs = null;
			approvers.clear();
			String sql = "select listapprove.ID,listapprove.IDGroupApprove,listapprove.IDEmployee,listapprove.IDtypeApprove," +
					"listapprove.Order,listapprove.IDStatus,listapprove.DateApprove,listapprove.Description " +
					"from listapprove,approvedoc where  listapprove.IDGroupApprove=approvedoc.IDGroupApprove and approvedoc.IDApproveDoc="
					+ document.getiDApproveDoc();

			rs = mysqlHelper.executeQuery(sql);
			while (rs.next()) {
				approvers.add(new ListApprove(rs.getString("listapprove.IDGroupApprove"), rs.getString("listapprove.IDEmployee"), 
						rs.getInt("listapprove.IDtypeApprove"), rs.getInt("listapprove.Order"),rs.getInt("listapprove.IDStatus"),
						rs.getTimestamp("listapprove.DateApprove"),rs.getString("listapprove.Description")));
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			mysqlHelper.close();
		}
		return approvers;
	}
}
